<template>
  <div class="cardBody">
    <div class="cardBodyItem wow fadeInDown" :data-wow-delay="index * 0.3 + 's'" v-for="(item, index) in list"
      :key="index">
      <div class="num">
        <gsapNum :decimal="item.decimal" :number="item.num"></gsapNum>
       <span style="color: #fff;"> {{item.unit}}</span>
      </div>
      <pedestal :skin="'skin' + (index + 1)"></pedestal>
      <div class="title">{{ item.title }}</div>
    </div>
  </div>
</template>

<script>
import gsapNum from "@/components/gsapNum/index.vue";
import pedestal from "./pedestal.vue";
import { getDeviceStatistic } from '@/api/iot/device'
import { method } from "lodash";

export default {
  name: "title",
  data() {
    return {
      list: [
        // {
        //   title: '计划巡检',
        //   decimal: false,
        //   num: 5788.11,
        //   unit: 'km'
        // }, {
        //   title: '实际巡检',
        //   decimal: false,
        //   num: 3677.55,
        //   unit: 'km'
        // },
        //  {
        //   title: '计划保养',
        //   decimal: false,
        //   num: 120,
        //   unit: '个'
        // },
        //  {
        //   title: '实际保养',
        //   decimal: false,
        //   num: 48,
        //   unit: '个'
        // }
      ]
    }
  },
  components: { gsapNum, pedestal },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      getDeviceStatistic().then((res) => {
        if (res.code == 200) {
          let obj = {
            title: '总数量',
            decimal: false,
            num: res.data.alertCount,
            unit: '个'
          }
          this.list.push(obj)

          let obj2 = {
            title: '已处理',
            decimal: false,
            num: res.data.alertProcessedCount,
            unit: '个'
          }
          this.list.push(obj2)

          let obj3 = {
            title: '未处理',
            decimal: false,
            num: res.data.alertNotProcessedCount,
            unit: '个'
          }
          this.list.push(obj3)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.cardBody {
  position: relative;
  width: calc(100% - 0px);
  margin: 0 auto;
  height: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  flex-direction: row;
  align-content: flex-start;

  .cardBodyItem {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: column;
    align-content: flex-start;
    width: calc(50% - 10px);
    margin: 5px;
    box-sizing: border-box;
    height: calc(50% - 41px);
    background: linear-gradient(360deg, rgba(0, 81, 155, 0.14) 0%, rgba(0, 89, 154, 0.04) 100%);
    box-shadow: inset 0px 0px 68px 0px rgba(0, 133, 255, 0.15);
    opacity: 1;
    border: 1px solid rgba(0, 133, 255, 0.06);

    .title {
      font-size: 14px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: #FFFFFF;
      margin-bottom: 0px;
      margin-top: 20px;
    }

    .num {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      position: relative;
      z-index: 12;
      margin-bottom: -10px;
    }

    :deep(.num) {
      .gsapNum {
        font-size: 22px;
        font-family: PangMenZhengDao;
        font-weight: 400;
        background: linear-gradient(180deg, #FFFFFF 0%, #00FFFF 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .cardBodyItem:nth-child(2) {
    :deep(.num) {
      .gsapNum {
        background: linear-gradient(180deg, #FFFFFF 0%, #60FF8C 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .cardBodyItem:nth-child(3) {
    :deep(.num) {
      .gsapNum {
        background: linear-gradient(180deg, #FFFFFC 0%, #FFEE58 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .cardBodyItem:nth-child(4) {
    :deep(.num) {
      .gsapNum {
        background: linear-gradient(180deg, #FFFFFC 0%, #F0484C 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }
}
</style>
